﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

namespace SNAIL
{
    /// <summary>
    /// Interaktionslogik für UserControl2.xaml
    /// </summary>
    public partial class UserControl2 : UserControl
    {
        public UserControl2()
        {
            InitializeComponent();
            InitializeData();
        }

        private void InitializeData()
        {
            // PersonList.ItemsSource = PersonMock.GetPeople();
        }

        private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
        }
    }

    public class Person
    {
        public String FirstName { get; set; }
        public String LastName { get; set; }

        public override string ToString()
        {
            return String.Format("{0}, {1}", LastName, FirstName);
        }
    }

    public class PersonCollection : ObservableCollection<Person>
    {
    }

    public static class PersonMock
    {
        private static PersonCollection people =
            new PersonCollection();

        public static PersonCollection GetPeople()
        {
            if (people.Count > 0)
                return people;

            for (int i = 0; i < 10; i++)
                people.Add
                    (
                        new Person
                        {
                            FirstName = "FirstName" + i.ToString(),
                            LastName = "LastName" + i.ToString()
                        }
                    );

            return people;
        }
    }
}
